package com.example;

public class Grade {
    private String courseName;
    private double score;
    private String semester;
    private String courseType; // 例如：必修、选修
    private String studentUsername; // 关联学生用户
    private String examTime; // 考试时间
    private String teacherName; // 任课教师
    private String studentName; // 添加学生姓名

    public Grade(String courseName, double score, String semester, String courseType, String studentUsername, String examTime, String teacherName) {
        this.courseName = courseName;
        this.score = score;
        this.semester = semester;
        this.courseType = courseType;
        this.studentUsername = studentUsername;
        this.examTime = examTime;
        this.teacherName = teacherName;
        // studentName 在通过JOIN查询时设置
        this.studentName = null; 
    }
    
    // 新增一个构造函数，用于包含学生姓名的查询结果
    public Grade(String courseName, double score, String semester, String courseType, String studentUsername, String examTime, String teacherName, String studentName) {
        this.courseName = courseName;
        this.score = score;
        this.semester = semester;
        this.courseType = courseType;
        this.studentUsername = studentUsername;
        this.examTime = examTime;
        this.teacherName = teacherName;
        this.studentName = studentName;
    }

    // Getters
    public String getCourseName() {
        return courseName;
    }

    public double getScore() {
        return score;
    }

    public String getSemester() {
        return semester;
    }

    public String getCourseType() {
        return courseType;
    }

    public String getStudentUsername() {
        return studentUsername;
    }

    public String getExamTime() {
        return examTime;
    }

    public String getTeacherName() {
        return teacherName;
    }
    
    // 新增学生姓名的Getter
    public String getStudentName() {
        return studentName;
    }

    // Setter for studentName (optional, could be set in DAO)
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }
    
    // Added setScore method
    public void setScore(double score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Grade{" +
               "courseName='" + courseName + '\'' +
               ", score=" + score +
               ", semester='" + semester + '\'' +
               ", courseType='" + courseType + '\'' +
               ", studentUsername='" + studentUsername + '\'' +
               ", examTime='" + examTime + '\'' +
               ", teacherName='" + teacherName + '\'' +
               ", studentName='" + studentName + '\'' +
               '}';
    }
}